<?php
/*
*采集千团网中团购网站信息
*lsj 2010-08-23
*/

require_once '../inc.php';

$res = file_get_contents('http://www.1000tuan.com/sites.php');

if($res){
	$res = str_replace(array("\r", "\n", "\t", ' '), '', $res);
	preg_match_all('|"href="([^"]*)">([^<]*)</a></li>|U', $res, $web);

	if($web[1]){
		foreach($web[1] as $key=>$val){
			$site = parse_url($val);
			$site = 'http://'.$site[host];
			$name = $web[2][$key];
			//echo $key.': '.$name.'<br />';
			$sql = "select id from x_website where 1 and webname='{$name}' limit 0,1";
			if(!$db->select_var($sql)){
				$sql = "insert into x_website(webname,weburl) values('{$name}','{$site}')";
				echo $sql."<br />\n";
				$db->query($sql);
			}
		}
		
	}

}






?>
